From 4036e7f5e64558a5a81e390021bb417bc3457c0f Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 17 Mar 2004 00:17:07 +0000 Subject: [PATCH] Move the repositioning logic from _gtk_entry_completion() popup over here. Wed Mar 17 01:20:28 2004 Matthias Clasen * gtk/gtkentrycompletion.c (_gtk_entry_completion_resize_popup): Move the repositioning logic from _gtk_entry_completion() popup over here. Fixes #137355, reported by Niklas Knutsson. --- ChangeLog | 6 ++++ ChangeLog.pre-2-10 | 6 ++++ ChangeLog.pre-2-4 | 6 ++++ ChangeLog.pre-2-6 | 6 ++++ ChangeLog.pre-2-8 | 6 ++++ gtk/gtkentrycompletion.c | 61 +++++++++++++++++++--------------------- 6 files changed, 59 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index e7b2c9518c..b31a6ee6e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Mar 17 01:20:28 2004 Matthias Clasen + + * gtk/gtkentrycompletion.c (_gtk_entry_completion_resize_popup): + Move the repositioning logic from _gtk_entry_completion() popup + over here. Fixes #137355, reported by Niklas Knutsson. + Tue Mar 16 13:29:58 2004 Owen Taylor * === Released 2.4.0 === diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index e7b2c9518c..b31a6ee6e6 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +Wed Mar 17 01:20:28 2004 Matthias Clasen + + * gtk/gtkentrycompletion.c (_gtk_entry_completion_resize_popup): + Move the repositioning logic from _gtk_entry_completion() popup + over here. Fixes #137355, reported by Niklas Knutsson. + Tue Mar 16 13:29:58 2004 Owen Taylor * === Released 2.4.0 === diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index e7b2c9518c..b31a6ee6e6 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,9 @@ +Wed Mar 17 01:20:28 2004 Matthias Clasen + + * gtk/gtkentrycompletion.c (_gtk_entry_completion_resize_popup): + Move the repositioning logic from _gtk_entry_completion() popup + over here. Fixes #137355, reported by Niklas Knutsson. + Tue Mar 16 13:29:58 2004 Owen Taylor * === Released 2.4.0 === diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index e7b2c9518c..b31a6ee6e6 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,9 @@ +Wed Mar 17 01:20:28 2004 Matthias Clasen + + * gtk/gtkentrycompletion.c (_gtk_entry_completion_resize_popup): + Move the repositioning logic from _gtk_entry_completion() popup + over here. Fixes #137355, reported by Niklas Knutsson. + Tue Mar 16 13:29:58 2004 Owen Taylor * === Released 2.4.0 === diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index e7b2c9518c..b31a6ee6e6 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,9 @@ +Wed Mar 17 01:20:28 2004 Matthias Clasen + + * gtk/gtkentrycompletion.c (_gtk_entry_completion_resize_popup): + Move the repositioning logic from _gtk_entry_completion() popup + over here. Fixes #137355, reported by Niklas Knutsson. + Tue Mar 16 13:29:58 2004 Owen Taylor * === Released 2.4.0 === diff --git a/gtk/gtkentrycompletion.c b/gtk/gtkentrycompletion.c index 6cdc07584e..3ce0ac07ad 100644 --- a/gtk/gtkentrycompletion.c +++ b/gtk/gtkentrycompletion.c @@ -1089,10 +1089,19 @@ get_borders (GtkEntry *entry, gint _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion) { + gint x, y; gint items, height, x_border, y_border; + GdkScreen *screen; + gint monitor_num; + GdkRectangle monitor; + GtkRequisition popup_req; + gdk_window_get_origin (completion->priv->entry->window, &x, &y); get_borders (GTK_ENTRY (completion->priv->entry), &x_border, &y_border); + x += x_border; + y += 2 * y_border; + items = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (completion->priv->filter_model), NULL); items = MIN (items, 15); @@ -1129,18 +1138,31 @@ _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion) else gtk_widget_hide (completion->priv->action_view); + gtk_widget_size_request (completion->priv->popup_window, &popup_req); + + screen = gtk_widget_get_screen (GTK_WIDGET (completion->priv->entry)); + monitor_num = gdk_screen_get_monitor_at_window (screen, + GTK_WIDGET (completion->priv->entry)->window); + gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); + + if (x < monitor.x) + x = monitor.x; + else if (x + popup_req.width > monitor.x + monitor.width) + x = monitor.x + monitor.width - popup_req.width; + + if (y + height + popup_req.height <= monitor.y + monitor.height) + y += height; + else + y -= popup_req.height; + + gtk_window_move (GTK_WINDOW (completion->priv->popup_window), x, y); + return height; } void _gtk_entry_completion_popup (GtkEntryCompletion *completion) { - gint x, y, x_border, y_border; - gint height; - GdkScreen *screen; - gint monitor_num; - GdkRectangle monitor; - GtkRequisition popup_req; GtkTreeViewColumn *column; GList *renderers; @@ -1157,32 +1179,7 @@ _gtk_entry_completion_popup (GtkEntryCompletion *completion) gtk_widget_show_all (completion->priv->vbox); - gdk_window_get_origin (completion->priv->entry->window, &x, &y); - get_borders (GTK_ENTRY (completion->priv->entry), &x_border, &y_border); - - x += x_border; - y += 2 * y_border; - - height = _gtk_entry_completion_resize_popup (completion); - - gtk_widget_size_request (completion->priv->popup_window, &popup_req); - - screen = gtk_widget_get_screen (GTK_WIDGET (completion->priv->entry)); - monitor_num = gdk_screen_get_monitor_at_window (screen, - GTK_WIDGET (completion->priv->entry)->window); - gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); - - if (x < monitor.x) - x = monitor.x; - else if (x + popup_req.width > monitor.x + monitor.width) - x = monitor.x + monitor.width - popup_req.width; - - if (y + height + popup_req.height <= monitor.y + monitor.height) - y += height; - else - y -= popup_req.height; - - gtk_window_move (GTK_WINDOW (completion->priv->popup_window), x, y); + _gtk_entry_completion_resize_popup (completion); gtk_widget_show (completion->priv->popup_window); -- 2.30.2